close = function(n) return(c(n,n[1]));
files = list.files("Data\\paths\\normalized")

n = length(files)

avg = data.matrix(read.table("Data\\paths\\norm_average"))
xy = vector("list", n) # create list
diff = vector("numeric",n)

for(i in 1:n){
	xy[[i]] = data.matrix(read.table(paste("Data\\paths\\normalized\\",files[i],sep="")))
	diff[i] = sum(abs(xy[[i]]-avg))
}

#hist(diff)

# arbitrarely chosen
threshold = 3*sd(diff)


outlier_candidates = files[diff>threshold]
for(name in outlier_candidates){
	file.rename(paste("Images - Analysis\\",name,".jpg",sep=""),"Images - For manual verification\\",name,".jpg",sep="")
}